package org.aplikator.client.shared.descriptor;

import org.jboss.errai.common.client.api.annotations.Portable;

import java.util.ArrayList;
import java.util.List;

/**
 * @author vlahoda
 */

@Portable
public class QueryDescriptorDTO extends ClientDescriptorBase implements Cloneable{

    private List<QueryParameter> queryParameters = new ArrayList<QueryParameter>();

    @SuppressWarnings("unused")
    public QueryDescriptorDTO() { //TODO custom marshaller
    }

    public QueryDescriptorDTO(String id, String localizedName) {
        super(id, localizedName);
    }


    public QueryDescriptorDTO addQueryParameter(QueryParameter param){
        queryParameters.add(param);
        return this;
    }

    public List<QueryParameter> getQueryParameters(){
        return queryParameters;
    }
    
    public void setQueryParameters(List<QueryParameter> queryParameters) {
		this.queryParameters = queryParameters;
	}

    public QueryDescriptorDTO clone(){
        QueryDescriptorDTO retval = new QueryDescriptorDTO(getId(),getLocalizedName());
        for (QueryParameter par: queryParameters){
            retval.addQueryParameter(new QueryParameter(par.getName()));
        }
        return retval;
    }
}
